package com.appkubes.mall.admin.application.user.account.history.service.impl;

import com.appkubes.mall.admin.application.user.account.history.service.UserAccountHistoryService;
import com.appkubes.mall.core.common.constants.MallUserAccountHistoryConstants;
import com.appkubes.mall.core.entity.MallUserAccountHistory;
import com.appkubes.mall.core.service.impl.BaseMallUserAccountHistoryServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class UserAccountHistoryServiceImpl extends BaseMallUserAccountHistoryServiceImpl implements UserAccountHistoryService {


    /**
     * 获取账户记录信息, 已经根据三入参，设置了唯一性索引
     *
     * @param orderKey
     * @return
     */
    @Override
    public MallUserAccountHistory getAccountOrderHistory(String orderKey) {
        return getAccountHistory(MallUserAccountHistoryConstants.SourceType.ORDER.name(), orderKey);
    }

    /**
     * 减少参数，获取用户指定的账户订单佣金收入情况
     *
     * @param sourceType
     * @param sourceKey
     * @return
     */
    public MallUserAccountHistory getAccountHistory(String sourceType, String sourceKey) {
        MallUserAccountHistory query = new MallUserAccountHistory();
        query.setSourceType(sourceType);
        query.setSourceKey(sourceKey);
        return this.getOneByEntity(query);
    }


}
